﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeatlesBlog.SimConnect;
using FA.Library.Sim.Aircraft;
using FA.Library.Util;
using System.ComponentModel;

namespace FA.Plugins.FSXPlugin.Sim.Aircraft
{
    [DataStruct()]
    public class FSXAircraftInstruments : BaseCloneable, AircraftInstruments
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// True airspeed.
        /// </summary>
        [DataItem("AIRSPEED TRUE", "knots")]
        public float AirspeedTrue
        {
            get { return _airspeedTrue; }
            set
            {
                if (_airspeedTrue != value)
                {
                    _airspeedTrue = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AirspeedTrue"));
                }
            }
        }
        private float _airspeedTrue;

        /// <summary>
        /// Indicated airspeed.
        /// </summary>
        [DataItem("AIRSPEED INDICATED", "knots")]
        public float AirspeedIndicated
        {
            get { return _airspeedIndicated; }
            set
            {
                if (_airspeedIndicated != value)
                {
                    _airspeedIndicated = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AirspeedIndicated"));
                }
            }
        }
        private float _airspeedIndicated;

        /// <summary>
        /// Angle of “True” calibration scale on airspeed indicator.
        /// </summary>
        [DataItem("AIRSPEED TRUE CALIBRATE", "degrees")]
        public float AirspeedTrueCalibrate
        {
            get { return _airspeedTrueCalibrate; }
            set
            {
                if (_airspeedTrueCalibrate != value)
                {
                    _airspeedTrueCalibrate = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AirspeedTrueCalibrate"));
                }
            }
        }
        private float _airspeedTrueCalibrate;

        /// <summary>
        /// Redline airspeed (dynamic on some aircraft).
        /// </summary>
        [DataItem("AIRSPEED BARBER POLE", "knots")]
        public float AirspeedRedLine
        {
            get { return _airspeedRedLine; }
            private set
            {
                if (_airspeedRedLine != value)
                {
                    _airspeedRedLine = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AirspeedRedLine"));
                }
            }
        }
        private float _airspeedRedLine;
        
        /// <summary>
        /// Vertical speed indication.
        /// </summary>
        [DataItem("VERTICAL SPEED", "feet per second")]
        public float VerticalSpeed
        {
            get { return _verticalSpeed; }
            set
            {
                if (_verticalSpeed != value)
                {
                    _verticalSpeed = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("VerticalSpeed"));
                }
            }
        }
        private float _verticalSpeed;

        /// <summary>
        /// Stall warning.
        /// </summary>
        [DataItem("STALL WARNING", "bool")]
        public bool StallWarning
        {
            get { return _stallWarning; }
            private set
            {
                if (_stallWarning != value)
                {
                    _stallWarning = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("StallWarning"));
                }
            }
        }
        private bool _stallWarning;

        /// <summary>
        /// Overspeed warning.
        /// </summary>
        [DataItem("OVERSPEED WARNING", "bool")]
        public bool OverspeedWarning
        {
            get { return _overspeedWarning; }
            private set
            {
                if (_overspeedWarning != value)
                {
                    _overspeedWarning = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("OverspeedWarning"));
                }
            }
        }
        private bool _overspeedWarning;

        /// <summary>
        /// Altimeter indication.
        /// </summary>
        [DataItem("INDICATED ALTITUDE", "feet")]
        public float AltimeterIndication
        {
            get { return _altimeterIndication; }
            set
            {
                if (_altimeterIndication != value)
                {
                    _altimeterIndication = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AltimeterIndication"));
                }
            }
        }
        private float _altimeterIndication;

        /// <summary>
        /// Altimeter setting.
        /// </summary>
        [DataItem("KOHLSMAN SETTING MB", "inHg")]
        public float AltimeterSettingMB
        {
            get { return _altimeterSettingMB; }
            set
            {
                if (_altimeterSettingMB != value)
                {
                    _altimeterSettingMB = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AltimeterSettingMB"));
                }
            }
        }
        private float _altimeterSettingMB;

        /// <summary>
        /// Attitude Indicator pitch indication.
        /// </summary>
        [DataItem("ATTITUDE INDICATOR PITCH DEGREES", "radians")]
        public float AttitudeIndicatorPitch
        {
            get { return _altimeterIndicatorPitch; }
            private set
            {
                if (_altimeterIndicatorPitch != value)
                {
                    _altimeterIndicatorPitch = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AttitudeIndicatorPitch"));
                }
            }
        }
        private float _altimeterIndicatorPitch;

        /// <summary>
        /// Attitude Indicator bank indication.
        /// </summary>
        [DataItem("ATTITUDE INDICATOR BANK DEGREES", "radians")]
        public float AttitudeIndicatorBank
        {
            get { return _attitudeIndicatorBank; }
            private set
            {
                if (_attitudeIndicatorBank != value)
                {
                    _attitudeIndicatorBank = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AttitudeIndicatorBank"));
                }
            }
        }
        private float _attitudeIndicatorBank;

        /// <summary>
        /// Attitude Indicator pitch reference bars.
        /// </summary>
        [DataItem("ATTITUDE BARS POSITION", "percent")]
        public float AttitudeIndicatorPitchBarsPosition
        {
            get { return _attitudeIndicatorPitch; }
            private set
            {
                if (_attitudeIndicatorPitch != value)
                {
                    _attitudeIndicatorPitch = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AttitudeIndicatorPitchBarsPosition"));
                }
            }
        }
        private float _attitudeIndicatorPitch;

        /// <summary>
        /// Attitude Indicator caged state.
        /// </summary>
        [DataItem("ATTITUDE CAGE", "bool")]
        public bool AttitudeIndicatorCaged
        {
            get { return _attitudeIndicatorCaged; }
            private set
            {
                if (_attitudeIndicatorCaged != value)
                {
                    _attitudeIndicatorCaged = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AttitudeIndicatorCaged"));
                }
            }
        }
        private bool _attitudeIndicatorCaged;

        /// <summary>
        /// Magnetic compass indication.
        /// </summary>
        [DataItem("WISKEY COMPASS INDICATION DEGREES", "degrees")]
        public float MagneticCompassIndication
        {
            get { return _magneticCompassIndication; }
            set
            {
                if (_magneticCompassIndication != value)
                {
                    _magneticCompassIndication = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("MagneticCompassIndication"));
                }
            }
        }
        private float _magneticCompassIndication;

        /// <summary>
        /// Heading indicator gyro. 
        /// </summary>
        [DataItem("PLANE HEADING DEGREES GYRO", "radians")]
        public float HeadingIndicator
        {
            get { return _headingIndicator; }
            set
            {
                if (_headingIndicator != value)
                {
                    _headingIndicator = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("HeadingIndicator"));
                }
            }
        }
        private float _headingIndicator;

        /// <summary>
        /// Rate of turn of heading indicator.
        /// </summary>
        [DataItem("DELTA HEADING RATE", "radians per second")]
        public float HeadingIndicatorDeltaRate
        {
            get { return _headingIndicatorDeltaRate; }
            set
            {
                if (_headingIndicatorDeltaRate != value)
                {
                    _headingIndicatorDeltaRate = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("HeadingIndicatorDeltaRate"));
                }
            }
        }
        private float _headingIndicatorDeltaRate;

        /// <summary>
        /// Angular error of heading indicator.
        /// </summary>
        [DataItem("GYRO DRIFT ERROR", "radians")]
        public float HeadingIndicatorDriftError
        {
            get { return _headingIndicatorDriftError; }
            private set
            {
                if (_headingIndicatorDriftError != value)
                {
                    _headingIndicatorDriftError = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("HeadingIndicatorDriftError"));
                }
            }
        }
        private float _headingIndicatorDriftError;

        /// <summary>
        /// Turn coordinator ball from -127 to 127.
        /// </summary>
        [DataItem("TURN COORDINATOR BALL", "position")]
        public float TurnCoordinatorBallPosition
        {
            get { return _turnCorrdinatorBallPos; }
            private set
            {
                if (_turnCorrdinatorBallPos != value)
                {
                    _turnCorrdinatorBallPos = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("TurnCoordinatorBallPosition"));
                }
            }
        }
        private float _turnCorrdinatorBallPos;

        /// <summary>
        /// Angle of attack indicator.
        /// </summary>
        [DataItem("ANGLE OF ATTACK INDICATOR", "radians")]
        public float AngleOfAttackIndicator
        {
            get { return _angleOfAttackIndicator; }
            private set
            {
                if (_angleOfAttackIndicator != value)
                {
                    _angleOfAttackIndicator = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("AngleOfAttackIndicator"));
                }
            }
        }
        private float _angleOfAttackIndicator;

        /// <summary>
        /// Radar altitude.
        /// </summary>
        [DataItem("RADIO HEIGHT", "feet")]
        public float RadarAltitude
        {
            get { return _radarAltitude; }
            private set
            {
                if (_radarAltitude != value)
                {
                    _radarAltitude = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("RadarAltitude"));
                }
            }
        }
        private float _radarAltitude;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL ADF", 32)]
        public bool PanelADF
        {
            get { return _panelADF; }
            set
            {
                if (_panelADF != value)
                {
                    _panelADF = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelADF"));
                }
            }
        }
        private bool _panelADF;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL AIRSPEED", 32)]
        public bool PanelAirspeed
        {
            get { return _panelAirspeed; }
            set
            {
                if (_panelAirspeed != value)
                {
                    _panelAirspeed = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelAirspeed"));
                }
            }
        }
        private bool _panelAirspeed;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL ALTIMETER", 32)]
        public bool PanelAltimeter
        {
            get { return _panelAltimeter; }
            set
            {
                if (_panelAltimeter != value)
                {
                    _panelAltimeter = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelAltimeter"));
                }
            }
        }
        private bool _panelAltimeter;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL ATTITUDE", 32)]
        public bool PanelAttitude
        {
            get { return _panelAttitude; }
            set
            {
                if (_panelAttitude != value)
                {
                    _panelAttitude = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelAttitude"));
                }
            }
        }
        private bool _panelAttitude;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL COMM", 32)]
        public bool PanelComm
        {
            get { return _panelComm; }
            set
            {
                if (_panelComm != value)
                {
                    _panelComm = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelComm"));
                }
            }
        }
        private bool _panelComm;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL COMPASS", 32)]
        public bool PanelCompass
        {
            get { return _panelCompass; }
            set
            {
                if (_panelCompass != value)
                {
                    _panelCompass = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelCompass"));
                }
            }
        }
        private bool _panelCompass;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL ELECTRICAL", 32)]
        public bool PanelElectrical
        {
            get { return _panelElectrical; }
            set
            {
                if (_panelElectrical != value)
                {
                    _panelElectrical = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelElectrical"));
                }
            }
        }
        private bool _panelElectrical;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL AVIONICS", 32)]
        public bool PanelAvionics
        {
            get { return _panelAvionics; }
            private set
            {
                if (_panelAvionics != value)
                {
                    _panelAvionics = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelAvionics"));
                }
            }
        }
        private bool _panelAvionics;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL ENGINE", 32)]
        public bool PanelEngine
        {
            get { return _panelEngine; }
            set
            {
                if (_panelEngine != value)
                {
                    _panelEngine = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelEngine"));
                }
            }
        }
        private bool _panelEngine;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL FUEL INDICATOR", 32)]
        public bool PanelFuelIndicator
        {
            get { return _panelFuelIndicator; }
            private set
            {
                if (_panelFuelIndicator != value)
                {
                    _panelFuelIndicator = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelFuelIndicator"));
                }
            }
        }
        private bool _panelFuelIndicator;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL HEADING", 32)]
        public bool PanelHeading
        {
            get { return _panelHeading; }
            set
            {
                if (_panelHeading != value)
                {
                    _panelHeading = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelHeading"));
                }
            }
        }
        private bool _panelHeading;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL VERTICAL VELOCITY", 32)]
        public bool PanelVerticalVelocity
        {
            get { return _panelVerticalVelocity; }
            set
            {
                if (_panelVerticalVelocity != value)
                {
                    _panelVerticalVelocity = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelVerticalVelocity"));
                }
            }
        }
        private bool _panelVerticalVelocity;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL TRANSPONDER", 32)]
        public bool PanelTransponder
        {
            get { return _panelTransponder; }
            set
            {
                if (_panelTransponder != value)
                {
                    _panelTransponder = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelTransponder"));
                }
            }
        }
        private bool _panelTransponder;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL NAV", 32)]
        public bool PanelNav
        {
            get { return _panelNav; }
            set
            {
                if (_panelNav != value)
                {
                    _panelNav = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelNav"));
                }
            }
        }
        private bool _panelNav;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL PITOT", 32)]
        public bool PanelPitot
        {
            get { return _panelPitot; }
            set
            {
                if (_panelPitot != value)
                {
                    _panelPitot = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelPitot"));
                }
            }
        }
        private bool _panelPitot;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL TURN COORDINATOR", 32)]
        public bool PanelTurnCoordinator
        {
            get { return _panelTurnCoordinator; }
            private set
            {
                if (_panelTurnCoordinator != value)
                {
                    _panelTurnCoordinator = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelTurnCoordinator"));
                }
            }
        }
        private bool _panelTurnCoordinator;

        /// <summary>
        /// Gauge fail flag (0 = ok, 1 = fail, 2 = blank)
        /// </summary>
        [DataItem("PARTIAL PANEL VACUUM", 32)]
        public bool PanelVacuum
        {
            get { return _panelVacuum; }
            set
            {
                if (_panelVacuum != value)
                {
                    _panelVacuum = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("PanelVacuum"));
                }
            }
        }
        private bool _panelVacuum;

        /// <summary>
        /// Vacuum system suction pressure.
        /// </summary>
        [DataItem("SUCTION PRESSURE", "inHg")]
        public float SuctionPressure
        {
            get { return _suctionPressure; }
            set
            {
                if (_suctionPressure != value)
                {
                    _suctionPressure = value;
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs("SuctionPressure"));
                }
            }
        }
        private float _suctionPressure;
    }
}